#include <iostream>
#include <memory>
#include "TcpServer.hpp"
#include "Http.hpp"
using namespace std;

string ServerHandler(string &message)
{
    Http_Ns::Request req;
    req.Analyzing(message);
    req.Debug();

    Http_Ns::Response rep;
    string response = rep.HttpResponse(req);
    return response;
}

int main(int argc, char *argv[])
{
    if (argc != 2)
    {
        cout << "Incorrect use: " << endl
             << "    " << argv[0] << " port" << endl;
        return 1;
    }

    uint16_t port = stoi(argv[1]);

    unique_ptr<TcpServer> up(new TcpServer(port, ServerHandler));

    up->Loop();
    return 0;
}